// 从本地存储中获取token
const token = uni.getStorageSync('token');

const tokenfrom = {
	id: 0,
	username: null,
	password:null
}
if (token) {
	// Step 1: 拆分 Token
	const [headerB64, payloadB64, signature] = token.split('.');

	// Step 2: 解码头部和载荷
	const headerJson = atob(headerB64);
	const payloadJson = atob(payloadB64);

	// Step 3: 解析成 JavaScript 对象
	const header = JSON.parse(headerJson);
	const payload = JSON.parse(payloadJson);

	// Step 4: 获取载荷中的数据
	
	tokenfrom.id = payload.userId,
	tokenfrom.password = payload.password,
	tokenfrom.username = payload.username,
	// console.log("header----------"+header.JSON);
	// console.log("payload--------"+payload.password);
	
	uni.setStorageSync("userid",payload.userId);
	
}

export default tokenfrom;